package com.hjy.common.utils;

import com.hjy.api.HelloService;
import com.hjy.core.serializer.CommonSerializer;
import com.hjy.core.serializer.KryoSerializer;
import com.hjy.core.transport.RpcClient;
import com.hjy.core.transport.RpcClientProxy;
import com.hjy.core.transport.netty.client.NettyClient;
import com.hjy.core.transport.socket.client.SocketClient;

public class RpcUtils {

    public static <T> T getProxyObjetNetty(Class<T> tClass, CommonSerializer serializer) {
        RpcClient client = new NettyClient(serializer);
        RpcClientProxy proxy = new RpcClientProxy(client);
        return proxy.getProxy(tClass);
    }

    public static <T> T getProxyObjetNetty(Class<T> tClass) {
        RpcClient client = new NettyClient(new KryoSerializer());
        RpcClientProxy proxy = new RpcClientProxy(client);
        return proxy.getProxy(tClass);
    }

    public static <T> T getProxyObjetSocket(Class<T> tClass) {
        RpcClient client = new SocketClient();
        RpcClientProxy proxy = new RpcClientProxy(client);
        return proxy.getProxy(tClass);
    }
}
